import { createStore } from 'vuex'

export default createStore({
  state: {
    token:sessionStorage.getItem("token"),
    user:sessionStorage.getItem("user")?JSON.parse(sessionStorage.getItem("user")):{}
  },
  mutations:{
    setToken(state,token){
        state.token = token;
        sessionStorage.setItem("token",token);
    },
    setUser(state,user){
        state.user = user;
        sessionStorage.setItem("user", JSON.stringify(user) );
    }
  }
})
